/**
 * 财务报表实体类 - 财务文档管理和AI分析的核心实体
 *
 * 开发人员：陈宏伟
 * 开发时间：2025-10-25 至 2025-10-30
 * 模块职责：定义财务报表的业务属性和AI分析结果存储，作为报表AI分析的数据核心
 *
 * 技术要点：
 * - 多租户关联设计，与企业、用户实体关联
 * - 财务报表状态枚举管理，支持多种处理状态
 * - 文件信息存储和AI分析结果保存
 * - JSON字段存储复杂的AI分析结果
 * - 审计字段自动维护处理时间信息
 *
 * 开发故事：负责财务报表实体的数据模型设计，与报表AI分析服务深度配合，实现财务文档的智能分析和管理。
 */
package com.pbl.entity;

import com.pbl.common.enums.FinanceReportStatus;
import lombok.*;

import javax.persistence.*;
import java.time.LocalDateTime;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name = "finance_reports")
public class FinanceReport {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "enterprise_id", nullable = false)
    private Enterprise enterprise;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "uploaded_by_user_id")
    private User uploadedByUser;

    @Column(name = "file_name", nullable = false, length = 255)
    private String fileName;

    @Column(name = "file_type", nullable = false, length = 64)
    private String fileType;

    @Column(name = "file_size", nullable = false)
    private Integer fileSize;

    @Column(name = "storage_url", nullable = false, length = 512)
    private String storageUrl;

    @Enumerated(EnumType.STRING)
    @Column(nullable = false, length = 16)
    private FinanceReportStatus status;

    @Lob
    @Column(name = "analysis")
    private String analysis; // JSON text

    @Column(name = "processed_at")
    private LocalDateTime processedAt;

    @Column(name = "created_at", insertable = false, updatable = false)
    private LocalDateTime createdAt;

    @Column(name = "updated_at", insertable = false, updatable = false)
    private LocalDateTime updatedAt;
}
